﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Summary.aspx.cs" Inherits="UI_Mail_Summary" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title>摘要</title>
    <link href="../../js/jquery.easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery.easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery.easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../js/jquery.easyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script type="text/javascript">
     $(document).ready(function() {
       var orderID = request.QueryString('orderid');
       var eBayUserID = request.QueryString('ebayuserid');
       
       $('#orderinfo').datagrid({
         url: '../../TableHanders.aspx?act=q&tid=8001&type=0',
         columns:[[
           { field: 'ItemTitle', title: 'ItemTitle' },
           { field: 'Quantity', title: '数量' },
           { field: 'Price', title: '价格' },
           { field: 'Listing', title: '产品代码' },
           { field: 'ItemID', title: 'ItemID' }
         ]],
         view: cardview,
         queryParams: {
           'eBayUserID': eBayUserID,
           'OrderID': orderID
         },
         showHeader: false
       });

       $('#paymentinfo').datagrid({
         url: '../../TableHanders.aspx?act=q&tid=8002&type=0',
         columns: [[
           { field: 'TransactionID', title: '交易号' },
           { field: 'PaidonDate', title: '付款日期' },
           { field: 'Amount', title: '付款总额' },
           { field: 'PayPalFee', title: 'PayPal费' },
           { field: 'Gross', title: '净额' }
         ]],
         queryParams: {
           'eBayUserID': eBayUserID,
           'OrderID': orderID
         }
       });

       $.getJSON(
         './MailHandler.ashx?act=q&id=0201&ebayuserid=' + eBayUserID + '&orderid=' + orderID,
         function (data) {
           if (data.retVal == 0) {
             var parcel = data.retSrc.Parcel;
             for (i in parcel) {
               $('#parceluserid').text(parcel[i].BuyerID);
               $('#parcelstreect').text(parcel[i].BuyerStreect);
               $('#parcelcity').text(parcel[i].BuyerCity);
               $('#parcelcountry').text(parcel[i].BuyerCountry);
               $('#parcelzipcode').text(parcel[i].BuyerZipCode);
               $('#parceltelephone').text(parcel[i].BuyerTelephone);
               $('#parcelemail').text(parcel[i].BuyerEmail);
               $('#parcelid').text(parcel[i].ParcelID);
               $('#parceldate').text(parcel[i].DispatchDate);
               $('#parcelshippingservice').text(parcel[i].ShippingService);
               $('#parcelshippingservicebussiness').text(parcel[i].ShippingServiceBusseness);
               $('#parceltrackingno').text(parcel[i].TrackingNo);
               $('#parcelweight').text(parcel[i].ShippingServiceWeight + 'g');
               $('#parcelshippingservicecost').text(parcel[i].ShippingServiceCost);
             }

             var eBayAddress = data.retSrc.eBayAddress;
             for(i in eBayAddress) {
               $('#ebayname').text(eBayAddress[i].BuyerName);
               $('#ebaystreet').text(eBayAddress[i].BuyerAddress);
               $('#ebaycity').text(eBayAddress[i].BuyerCity);
               $('#ebaycountry').text(eBayAddress[i].BuyerCountry);
               $('#ebayzipcode').text(eBayAddress[i].BuyerZipCode);
               $('#ebayemail').text(eBayAddress[i].BuyerEmail);
             }

             var payPalAddress = data.retSrc.PayPalAddress;
             for(i in payPalAddress) {
               $('#paypalname').text(payPalAddress[i].BuyerName);
               $('#paypalstreet').text(payPalAddress[i].BuyerAddress);
               $('#paypalcity').text(payPalAddress[i].BuyerCity);
               $('#paypalcountry').text(payPalAddress[i].BuyerCountry);
               $('#paypalzipcode').text(payPalAddress[i].BuyerZipCode);
               $('#paypalemail').text(payPalAddress[i].BuyerEmail);
             }
           }
           else {
             alert(data.retMsg);
           }
         });
     });

     var cardview = $.extend({}, $.fn.datagrid.defaults.view, {
       renderRow: function (target, fields, frozen, rowIndex, rowData) {
         var cc = [];
         cc.push('<div style="margin-left:20px;padding-top:8px;">');
         cc.push('<div style="float:left;text-overflow:ellipsis;width:60%;white-space:nowrap;overflow:hidden;"><a href="http://www.ebay.co.uk/itm/' + rowData['ItemID'] + '" target="_blank" >' + rowData['ItemTitle'] + '</a></div>');
         cc.push('<div style="float:left;width:20%;">X ' + rowData['Quantity'] + '</div>');
         cc.push('<div style="float:left;width:20%;"> ' + (rowData['Price'] == '' ? '' : parseFloat(rowData['Price'], 2)) + '</div>');
         cc.push('<br />');
         cc.push('<div>产品代码: ' + rowData['Listing'] + '</div>');
         cc.push('<div>Item ID: ' + rowData['ItemID'] + '</div>');
         cc.push('</div>');
         return cc.join('');
       }
     });
     var request = {
       QueryString : function(val) {
         var url = window.location.search;
         var re = new RegExp('' +val+ '=([^&?]*)', 'ig');
         return ((url.match(re))?(url.match(re)[0].substr(val.length+1)):null);
       }
     };
    </script>
  </head>
  <body>
    <div style="padding-left:10px;">
      <span>订单号: </span><span id="orderID" runat="Server"></span>
      <span style="margin-left:40px">Buyer ID: </span><span id="buyerID" runat="Server"></span>
      <%--<span style="margin-left:40px">评价: </span><span id="feedback" runat="Server"></span>--%>
      <span style="margin-left:40px">订单状态: </span><span id="status" runat="Server"></span>
      <span style="margin-left:40px">是否重发: </span><span id="resend" runat="Server"></span>
      <span style="margin-left:40px">是否退款: </span><span id="refund" runat="Server"></span>
    </div>
    <div id="dvlayout" class="easyui-layout" data-options="fit:true">
      <div data-options="region:'east'" border="false" style="width:310px;margin-left:5px;">
        <div id="ebayaddress" class="easyui-panel" title="eBay地址" style="margin-bottom:10px;width:300px;height:auto;min-height:120px;color:blue;font-size:16px;padding:5px;">
          <span id="ebayname" runat="Server"></span><br />
          <span id="ebaystreet" runat="Server"></span><br />
          <span id="ebaycity" runat="Server"></span><br />
          <span id="ebaycountry" runat="Server"></span><br />
          <span id="ebayzipcode" runat="Server"></span><br />
          <span id="ebayemail" runat="Server"></span><br />
        </div>
        <div class="easyui-panel" title="PayPal地址" style="width:300px;height:auto;min-height:120px;color:blue;font-size:16px;padding:5px;">
          <span id="paypalname" runat="Server"></span><br />
          <span id="paypalstreet" runat="Server"></span><br />
          <span id="paypalcity" runat="Server"></span><br />
          <span id="paypalcountry" runat="Server"></span><br />
          <span id="paypalzipcode" runat="Server"></span><br />
          <span id="paypalemail" runat="Server"></span><br />
        </div>
      </div>
      <div data-options="region:'center'" border="false" style="width:300px;">
        <div class="easyui-panel" title="订单信息" style="margin-bottom:10px;fit:true;">
          <table id="orderinfo" border="0px"></table>
          <hr />
          <table>
            <tr>
              <td>客户选择发货方式: <span id="deliverytype" runat="Server"></span></td>
              <td>邮费: <span id="postage" runat="Server"></span></td>
            </tr>
            <tr>
              <td>销售日期: <span id="saledate" runat="Server"></span></td>
              <td>总价: <span id="totalprice" runat="Server"></span></td>
            </tr>
            <tr>
              <td>付款方式: <span id="paymenttype" runat="Server"></span></td>
              <td>付款状态: <span id="paymentstatus" runat="Server"></span></td>
            </tr>
          </table>
        </div>
        <div class="easyui-panel" title="付款信息" style="margin-bottom:10px;fit:true;min-height:100px;">
          <table id="paymentinfo" border="0"></table>
        </div>
        <div class="easyui-panel" title="发货信息" style="fit:true">
          <table>
            <tr>
              <td width="200px"><span id="parceluserid"></span></td>
              <td>发货单号: <span id="parcelid"></span></td>
            </tr>
            <tr>
              <td><span id="parcelstreect"></span></td>
              <td>发货时间: <span id="parceldate"></span></td>
            </tr>
            <tr>
              <td><span id="parcelcity"></span></td>
              <td>实际发货方式: <span id="parcelshippingservice"></span></td>
            </tr>
            <tr>
              <td><span id="parcelcountry></span></td>
              <td>发货公司: <span id="parcelshippingservicebussiness"></span></td>
            </tr>
            <tr>
              <td><span id="parcelzipcode"></span></td>
              <td>Tracking No.: <span id="parceltrackingno"></span></td>
            </tr>
            <tr>
              <td><span id="parceltelephone"></span></td>
              <td>重量: <span id="parcelweight"></span></td>
            </tr>
            <tr>
              <td><span id="parcelemail"></span></td>
              <td>预计邮费: <span id="parcelshippingservicecost"></span></td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </body>
</html>
